package others;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.LongAdder;

public class LongAdderTest {
    public static void main(String[] args) throws InterruptedException {
        LongAdder longAdder = new LongAdder();
        ExecutorService executors = Executors.newFixedThreadPool(10);
        for (int i = 0; i < 10; i++) {
            executors.execute(()->{
                longAdder.add(1);
            });
        }
        executors.shutdown();
        executors.awaitTermination(3, TimeUnit.SECONDS);
        System.out.println(longAdder.sum());
    }
}
